package cn.zhentao.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import cn.zhentao.pojo.TCarSeries;
import cn.zhentao.service.TCarSeriesService;

import java.util.List;

@RestController
@RequestMapping("carSeries")
public class CarSeriesController {

    @Autowired
    private TCarSeriesService tCarSeriesService;


    /**
     * 查询所有车系列表
     * @return 车系列表
     */
    @GetMapping("findList")
    public List<TCarSeries> findList() {
        return tCarSeriesService.list();
    }
    
    
    
    
    
        /**
         * 添加
         * @param carSeries 信息
         * @return 添加结果
         */
    
        @PostMapping("add")
        public String add(@RequestBody TCarSeries carSeries) {
            boolean save = tCarSeriesService.save(carSeries);
            return save ? "添加成功" : "添加失败";
        }
    
    
    
        /**
         * 修改
         * @param carSeries 信息
         * @return 修改结果
         */
        @PostMapping("update")
        public String update(@RequestBody TCarSeries carSeries) {
            boolean update = tCarSeriesService.updateById(carSeries);
            return update ? "修改成功" : "修改失败";
        }
    
    
        /**
         * 根据ID查询
         * @param id ID
         * @return 信息
         */
        @GetMapping("findById")
        public TCarSeries findById(@RequestParam Integer id) {
            return tCarSeriesService.getById(id);
        }
    
        /**
         * 删除
         * @param id ID
         * @return 删除结果
         */
        @GetMapping("delete")
        public String delete(@RequestParam Integer id) {
            boolean delete = tCarSeriesService.removeById(id);
            return delete ? "删除成功" : "删除失败";
        }
    
    

}
